/*
 * @Author: xiaoyangzhao
 * @Last Modified by:   xiaoyangzhao
 */

import request from '@/utils/request'
import { route_origins, route_path_get } from '@/api/routes'
import { routers } from './routes'

const path = 'listings/'

/**
 * [property: houseListing object array]
 * @param  {String} keywords        [query keywords: street, district, zipcode]
 * @return {Function}               [async]
 */

export function houseListing(params) {
    // console.log('houseList params:', params,',houseList services:', request._origin.transformRequest[0](params))
    return request({
        // url: 'http://54.197.116.132/listings/housingList',
        url: `${routers.prod.frk}${path}housingList`,
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        transformRequest: request._origin.transformRequest,
        params
    })
}

/**
 * [property details: house detail]
 * @param  {Number} id              [house id]
 * @return {Function}               [async]
 */

export function houseInfo(params) {
    return request({
        // url: 'http://54.197.116.132/listings/housingInfo/1',
        url: `${routers.prod.frk}${path}housingInfo/${params}`,
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        transformRequest: request._origin.transformRequest
        // data: params
    })
}

/**
 * [capRateForm: capital rate form]
 * @return {Function}               [async]
 */

export function capRateForm(params) {
    return request({
        url: `${routers.prod.frk}${path}cap_rate_form`,
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        transformRequest: request._origin.transformRequest,
        params
    })
}

/**
 * [getInfo 获取用户信息]
 * @param  {Array} token  [用户角色口令]
 * @return {Function}     [异步接口方法]
 */
export function getInfo(token) {
    return request({
        url: route_origins + route_path_get + 'user/info',
        method: 'get',
        params: {
            token,
            ajax: 'XMLHttpRequest'
        }
    })
}

/**
 * [userTodo 首页 待办事项]
 * @return {Function}     [异步接口方法]
 */
export function userTodo(params) {
    return request({
        url: route_origins + route_path_get + 'user/todo',
        method: 'get',
        params
    })
}

/**
 * [reportCoverHome 首页 覆盖率报表数据]
 * @return {Function}     [异步接口方法]
 */
export function reportCoverHome(params) {
    return request({
        url: route_origins + route_path_get + 'report/cover/query/home',
        method: 'get',
        params
    })
}
